Lab Assignment 1
Due date : August 27, 12 PM EST
Total Marks : 58
Important Note :
Today’s Exercise
|
Topics |
Lab Exercises |
Points |
|
Printing strings |
|
|
|
Identifiers |
|
|
Prelab Exercises
Your task is to write a Java program that will print out the following message (including the row of equal marks):
Computer Science, Yes!!!!
=========================
An outline of the program is below. Complete it as follows:
the program does.
// *******************************************************************
// File Name:
//
// Purpose:
// *******************************************************************
public class CSYes
{
// -------------------------------------------------
// The following main method prints an exciting
// message about computer science
// -------------------------------------------------
}
Poem
Write a Java program that prints the message, "Roses are red". Your program will be a class definition containing a main
Method. Remember the following:
Compile and run your program. When it works correctly, modify it so that it prints the entire poem:
Roses are red
Violets are blue
Sugar is sweet
And so are you!
Identifiers and Program Names
http://java.sun.com/docs/books/tutorial/java/nutsandbolts/_keywords.html
The various words that are used in a program are called identifiers. There are three types of identifiers:
File Simple.java contains a simple Java program that prints a message. The identifier that represents the name of this program
is Simple, but we could have chosen a different identifier subject to certain rules and conventions. Remember:
Complete the table below. Then save Simple.java to your directory and check your answers by modifying
it to try each—note that you will have to change the file name each time to match the program name or you will always get
an error.
// ********************************************
// Simple.java
//
// Print a simple message about Java.
//
// ********************************************
public class Simple
{
public static void main (String[] args)
{
System.out.println ("Java rocks!!");
}
}
|
Program Name |
Legal identifier? |
Why? |
Good choice of name? |
Why? |
|
simple |
|
|
|
|
|
SimpleProgram |
|
|
|
|
|
1Simple |
|
|
|
|
|
_Simple |
|
|
|
|
|
*Simple* |
|
|
|
|
|
$123_45 |
|
|
|
|
|
Simple! |
|
|
|
|